package com.ruoyi.front_desk.articles.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.front_desk.articles.domain.FrontdeskArticles;
import com.ruoyi.front_desk.articles.mapper.FrontdeskArticlesMapper;
import com.ruoyi.front_desk.articles.service.FrontdeskArticlesService;
import com.ruoyi.front_desk.domain.FrontdeskNameCategory;
import com.ruoyi.front_desk.service.FrontdeskNameCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import static com.ruoyi.common.utils.PageUtils.startPage;

/**
 * @author 刘奥旸
 * @version 1.0
 */
@Service
public class FrontdeskArticlesServiceImpl extends ServiceImpl<FrontdeskArticlesMapper, FrontdeskArticles> implements FrontdeskArticlesService {
@Autowired
private FrontdeskArticlesMapper frontdeskArticlesMapper;
    @Resource
    public FrontdeskNameCategoryService frontdeskNameCategoryService;

    @Override
    public FrontdeskArticles selectFrontdeskArticlesByIdService(Long id) {
        FrontdeskArticles frontdeskArticles = frontdeskArticlesMapper.selectFrontdeskArticlesById(id);
        Integer integer = frontdeskArticlesMapper.updateFrontdeskArticle(id);

        return frontdeskArticles;

    }

    @Override
    public List<FrontdeskArticles> selectFrontdeskArtilesmuti(Integer id) {
        List<Integer> ids = frontdeskNameCategoryService.selectnamebyid(id);
        if(ids.isEmpty()) {
            ids = Arrays.asList(id);
        }
        startPage();
        List<FrontdeskArticles> frontdeskArticles = frontdeskArticlesMapper.selectByIds(ids);
        return frontdeskArticles;
    }

}
